{{extend 'layout.html'}}
{{= A('Submit new job', _href=URL(r=request,c='plugin_pbs',f='new_job')) }}
<hr />
{{ if len(jobs) > 0: }}
<table>
  <tr>
    <th></th>
    <th>job id</th>
    <th>job name</th>
    <th>submitted by</th>
    <th>submitted time</th>
    <th>status</th>
    <th>script</th>
    <th>stdout</th>
    <th>stderr</th>
  </tr>
  {{ for j in jobs: }}
  <tr>
    <td>
      <form action="{{=URL(r=request,c='plugin_pbs',f='delete')}}" method="POST">
	<input type="hidden" name="job_id" value="{{=j.id}}" />
	<input type="submit" value="delete" style="font-size:9px;padding:0px;line-height:10px;" />
      </form>
    </td>
    <td>{{=j.job_id if j.job_id else 'not yet queued'}}</td>
    <td>{{=j.job_name}}</td>
    <td>{{=j.user_email}}</td>
    <td>{{=j.submitted_time}}</td>
    <td>{{=j.status}}</td>
    <td>{{= A('download script',_href=URL(r=request,c='plugin_pbs',f='get_file',args=['script',j.id])) }}</td>
    <td>{{= A('download stdout',_href=URL(r=request,c='plugin_pbs',f='get_file',args=['stdout',j.id])) if j.status == 'completed' else '---' }}</td>
    <td>{{= A('download stderr',_href=URL(r=request,c='plugin_pbs',f='get_file',args=['stderr',j.id])) if j.status == 'completed' else '---' }}</td>
  </tr>
  {{ pass }}
</table>
{{ else: }}
<h4>No jobs in queue</h4>
{{ pass }}
<hr />
{{= A('Refresh',_href='javascript:window.location.reload()') }}
